﻿/*
 * Created by SharpDevelop.
 * User: notmmao
 * Date: 2008-4-2
 * Time: 23:16
 * 
 */

using System;
using System.Drawing;

namespace Deebug.Games.ShortBoom
{
	/// <summary>
	/// The Player Class Of the Game.
	/// </summary>
	public class Player:Sprite
	{
		public Player(Gate word,Point location, Bitmap frame)
			:this(word,location.X,location.Y,frame)
		{
			
		}
		public Player(Gate word,int x,int y,Bitmap frame):base(word,x,y,frame)
		{
			//默认为静止
			this.Vector.X = 0.0f;
			this.Vector.Y = 0.0f;
			//默认其实速度为15像素/帧(Pixel/Frame);
			this.Speed = 15.0f;
		}
		
		public override void UpDate(float gameTime, float elapsedTime)
		{
			Vector.X=0.0f;
			//判断键盘输入，只做水平运动，所以不用改变Y
			if(KeyBoard.Left)this.Vector.X = -1.0f;
			if(KeyBoard.Right)this.Vector.X = 1.0f;
			
			//改变坐标
			base.UpDate(gameTime,elapsedTime);
			
			//判断玩家是否到边界
			if(this.Location.X<0)this.Location.X = 0;
			if(this.Location.X>this.Word.Width-this.Width)
				this.Location.X = this.Word.Width-this.Width;
		}
	}
}
